/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client;

/**
 *
 * @author Bartek
 */
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.math.BigDecimal;
import compute.Compute;
import java.util.ArrayList;
import java.util.List;

public class ComputePi {
    public static void main(String args[]) {
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new SecurityManager());
        }
        try {
            String name = "Compute";
            Registry registry = LocateRegistry.getRegistry(args[0]);
            Compute comp = (Compute) registry.lookup(name);
            Pi task = new Pi(Integer.parseInt(args[1]));
            
            Primes primesTask = new Primes(Integer.parseInt(args[2]));
            
            BigDecimal pi = comp.executeTask(task);
            List<Integer> primes = comp.executeTask(primesTask);
            
            
            System.out.println(pi);
            
            
            for (Integer prime : primes) {
                
                System.out.print(prime + " ");
            }
        } catch (Exception e) {
            System.err.println("ComputePi exception:");
            e.printStackTrace();
        }
    }    
}
